

use Data/Individual_withsolar.dta, replace
	
	
	

	gen peersolar = cum - (has_solar/1000)

  
  
  
	label variable peersolar "Peer Solar Rooftops (000s)"
	label variable has_solar "Adopted Solar"
  
  
	label variable median_income_interp "Median Income (AUD 000s)"
	label variable median_mortgage_interp "Median Mortgage Payment (AUD 000s)"
	label variable median_rent_interp "Median Rental Payment (AUD 000s)" 
	label variable PBachelor_interp "Proportion Bachelor's Degree"
	label variable PRented_interp "Proportion Rental Properties"
	label variable median_rooms_interp "Median House Size"
	label variable PFullTime_interp "Proportion Employed Full Time"
	label variable median_age_interp "Median Age"
  
	xtset postcode
  
  
	
* 3 quarters is nine months, total of 28 quarters in sample

	local length = 3
		 
	forval t = 0(1)`length' {
		gen event_after`t' =  SHCP_end ==`t' |  PFIT_starttime==`t' | PFIT_endtime==`t' | ///
		 SRES1_end ==`t' | SRES2_end==`t' | SRES_TFIT_endtime==`t' | FFIT_endtime==`t'
		 
		 
		 gen event_before`t' =  SHCP_end ==-`t'  | PFIT_starttime==-`t' | PFIT_endtime==-`t' | ///
		 SRES1_end ==-`t' | SRES2_end==-`t' | SRES_TFIT_endtime==-`t' | FFIT_endtime==-`t'
		
		gen event_after_new`t' = event_after`t'*peersolar
		gen event_before_new`t' = event_before`t'*peersolar
		
		
		gen has_after_new`t' = event_after`t'*has_solar
		gen has_before_new`t' = event_before`t'*has_solar
		
		
		
		drop event_after`t'
		drop event_before`t'
		
		
		
		}
			
		
	* reference time 
	drop    event_after_new0 // event_before_high1 event_before_new1


	label variable event_before_new3  "Event period -3"
	label variable event_before_new2  "Event period -2"
	label variable event_before_new1  "Event period -1"
	label variable event_before_new0  "Event period "
	label variable event_after_new1   "Event period +1"
	label variable event_after_new2   "Event period +2"
	label variable event_after_new3   "Event period +3"



	label variable has_before_new3  "Event period -3"
	label variable has_before_new2  "Event period -2"
	label variable has_before_new1  "Event period -1"
	label variable has_before_new0  "Event period "
	label variable has_after_new1   "Event period +1"
	label variable has_after_new2   "Event period +2"
	label variable has_after_new3   "Event period +3"

	
***********************
** 1. Including solar households not controling for adoption 
**********************	



	xi: xtivreg2 green_p  event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3 i.quarter  if roofrelativeIV<.  , fe cluster(postcode)

	eststo m3

	coefplot (m3, keep(event_before_new3  event_before_new2  event_before_new1) mcolor(blue) ciopts(lcolor(blue)) msymbol(o)) ///
	  (m3, keep(event_before_new0 ) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
	 (m3, keep(  event_after_new1 event_after_new2 event_after_new3 ) mcolor(red) ciopts(lcolor(red)) msymbol(o)), vertical ///
	 relocate(event_before_new3 = -2.84 event_before_new2 = -1.84 event_before_new1 = -0.84 event_before_new0 = -0 ///
	event_after_new1 =0.84  event_after_new2=1.84 event_after_new3=2.84 )   legend(off) yline(0) ///
		xtitle("Event time", size(large)) xlabel(-3(1)3, labsize(large))  xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin)) yscale(range(-0.025 0.025)) ylabel(-0.02(0.01)0.02, labsize(large)) 



	
graph export Analysis/Motivation_withsolar_peer.png, replace

	
	
	quietly summ green_plan if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	

outreg2 using Analysis/Individual_peersolarevent, bdec(3) se  nocons label  ctitle("FE")   ///
keep(event_before* event_after* )  addtext(Postcode FE, Yes, Year-Quarter FE, Yes , Mean dep var, 0`meandepvar') tex(fragment pretty) nonotes replace




***********************
** 2. Including solar households controling for adoption 
**********************	
	
	
	xi: xtivreg2 green_p has_solar event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3 i.quarter  if roofrelativeIV<.  , fe cluster(postcode)

	eststo m4
	
	
	
	coefplot (m4, keep(event_before_new3  event_before_new2  event_before_new1) mcolor(blue) ciopts(lcolor(blue)) msymbol(o)) ///
	  (m4, keep(event_before_new0 ) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
	 (m4, keep(  event_after_new1 event_after_new2 event_after_new3 ) mcolor(red) ciopts(lcolor(red)) msymbol(o)), vertical ///
	 relocate(event_before_new3 = -2.84 event_before_new2 = -1.84 event_before_new1 = -0.84 event_before_new0 = -0 ///
	event_after_new1 =0.84  event_after_new2=1.84 event_after_new3=2.84 )   legend(off) yline(0) ///
		xtitle("Event time", size(large)) xlabel(-3(1)3, labsize(large))  xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin)) yscale(range(-0.025 0.025)) ylabel(-0.02(0.01)0.02, labsize(large)) 


	
estimates save Analysis/Motivation_withsolar_peerhascont

graph export Analysis/Motivation_withsolar_peerhascont.png, replace

	
	
	
	
	quietly summ green_plan  if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	

outreg2 using Analysis/Individual_peersolarevent, bdec(3) se  nocons label  ctitle("FE")   ///
keep(event_before* event_after* has_solar)  addtext(Postcode FE, Yes, Year-Quarter FE, Yes ,Mean dep var, 0`meandepvar') tex(fragment pretty) nonotes append






***********************
** 3. Including solar households controling for adoption by event time  
**********************	
	


	xi: xtivreg2 green_p event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3 has_before_new3 has_before_new2 has_before_new1 has_before_new0 ///
	has_after_new1  has_after_new2 has_after_new3 i.quarter  if roofrelativeIV<.  , fe cluster(postcode)

	eststo m5
	
	
	
	coefplot (m5, keep(event_before_new3  event_before_new2  event_before_new1) mcolor(blue) ciopts(lcolor(blue)) msymbol(o)) ///
	  (m5, keep(event_before_new0 ) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
	 (m5, keep(  event_after_new1 event_after_new2 event_after_new3 ) mcolor(red) ciopts(lcolor(red)) msymbol(o)), vertical ///
	 relocate(event_before_new3 = -2.84 event_before_new2 = -1.84 event_before_new1 = -0.84 event_before_new0 = -0 ///
	event_after_new1 =0.84  event_after_new2=1.84 event_after_new3=2.84 )   legend(off) yline(0) ///
		xtitle("Event time", size(large)) xlabel(-3(1)3, labsize(large))  xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin)) yscale(range(-0.025 0.025)) ylabel(-0.02(0.01)0.02, labsize(large)) 

	
estimates save Analysis/Motivation_withsolar_peerhascont_event
	
graph export Analysis/Motivation_withsolar_peerhascont_event.png, replace

	
	

	
	coefplot (m5, keep(has_before_new3  has_before_new2  has_before_new1) mcolor(blue) ciopts(lcolor(blue)) msymbol(o)) ///
	  (m5, keep(has_before_new0 ) mcolor(gs0) ciopts(lcolor(gs0)) msymbol(o)) ///
	 (m5, keep(  has_after_new1 has_after_new2 has_after_new3 ) mcolor(red) ciopts(lcolor(red)) msymbol(o)), vertical ///
	 relocate(has_before_new3 = -2.84 has_before_new2 = -1.84 has_before_new1 = -0.84 has_before_new0 = -0 ///
	has_after_new1 =0.84  has_after_new2=1.84 has_after_new3=2.84 )   legend(off) yline(0) ///
		xtitle("Event time", size(large)) xlabel(-3(1)3, labsize(large))  xline(0, lcolor(gs10) lpattern(dash) lwidth(vthin)) yscale(range(-0.025 0.025)) ylabel(-0.02(0.01)0.02, labsize(large)) 

	
	
	graph export Analysis/Adopt_solargreen_event.png, replace

	
	
	
	
	quietly summ green_plan  if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	

outreg2 using Analysis/Individual_peersolarevent, bdec(3) se  nocons label  ctitle("FE")   ///
keep(event_before* event_after* has_solar has_before* has_after*)  addtext(Postcode FE, Yes, Year-Quarter FE, Yes ,Mean dep var, 0`meandepvar') tex(fragment pretty) nonotes append





